
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>docker04 镜像基本命令 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="docker05 容器基本命令.html" />
    
    
    <link rel="prev" href="docker03 docker原理.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="docker01 docker能干嘛.html">
            
                <a href="docker01 docker能干嘛.html">
            
                    
                    docker01 docker能干嘛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="docker02 安装docker.html">
            
                <a href="docker02 安装docker.html">
            
                    
                    docker02 安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="docker03 docker原理.html">
            
                <a href="docker03 docker原理.html">
            
                    
                    docker03 docker原理
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5" data-path="docker04 镜像基本命令.html">
            
                <a href="docker04 镜像基本命令.html">
            
                    
                    docker04 镜像基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="docker05 容器基本命令.html">
            
                <a href="docker05 容器基本命令.html">
            
                    
                    docker05 容器基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="docker06 常用其他命令.html">
            
                <a href="docker06 常用其他命令.html">
            
                    
                    docker06 常用其他命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="docker07 进入当前正在运行的容器.html">
            
                <a href="docker07 进入当前正在运行的容器.html">
            
                    
                    docker07 进入当前正在运行的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="docker08 部署nginx.html">
            
                <a href="docker08 部署nginx.html">
            
                    
                    docker08 部署nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="docker09 部署tomcat.html">
            
                <a href="docker09 部署tomcat.html">
            
                    
                    docker09 部署tomcat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="docker10 可视化面板.html">
            
                <a href="docker10 可视化面板.html">
            
                    
                    docker10 可视化面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="docker11 镜像原理.html">
            
                <a href="docker11 镜像原理.html">
            
                    
                    docker11 镜像原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="docker12 commit镜像.html">
            
                <a href="docker12 commit镜像.html">
            
                    
                    docker12 commit镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="docker13 容器数据卷.html">
            
                <a href="docker13 容器数据卷.html">
            
                    
                    docker13 容器数据卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="docker14 具名挂载和匿名挂载.html">
            
                <a href="docker14 具名挂载和匿名挂载.html">
            
                    
                    docker14 具名挂载和匿名挂载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="docker15 初始dockerfile.html">
            
                <a href="docker15 初始dockerfile.html">
            
                    
                    docker15 初始dockerfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="docker16 数据卷容器.html">
            
                <a href="docker16 数据卷容器.html">
            
                    
                    docker16 数据卷容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="docker17 dockerFile.html">
            
                <a href="docker17 dockerFile.html">
            
                    
                    docker17 dockerFile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="docker18 dockerFile基本命令.html">
            
                <a href="docker18 dockerFile基本命令.html">
            
                    
                    docker18 dockerFile基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="docker19 构建自己的centos.html">
            
                <a href="docker19 构建自己的centos.html">
            
                    
                    docker19 构建自己的centos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="docker20 发布镜像.html">
            
                <a href="docker20 发布镜像.html">
            
                    
                    docker20 发布镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="docker21 网络详情.html">
            
                <a href="docker21 网络详情.html">
            
                    
                    docker21 网络详情
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="docker22 容器互联.html">
            
                <a href="docker22 容器互联.html">
            
                    
                    docker22 容器互联
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="docker23 自定义网络.html">
            
                <a href="docker23 自定义网络.html">
            
                    
                    docker23 自定义网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                    
                    docker24 SpringBoot 微服务打包Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="docker25 dockerFile_demo.html">
            
                <a href="docker25 dockerFile_demo.html">
            
                    
                    docker25 dockerFile_demo
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >docker04 镜像基本命令</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x955C;&#x50CF;&#x57FA;&#x672C;&#x547D;&#x4EE4;">&#x955C;&#x50CF;&#x57FA;&#x672C;&#x547D;&#x4EE4;</h3>
<blockquote>
<p>&#x5E2E;&#x52A9;&#x547D;&#x4EE4;</p>
</blockquote>
<pre><code class="lang-shell">docker version # &#x663E;&#x793A;docker &#x7248;&#x672C;&#x4FE1;&#x606F;
docker info     # &#x663E;&#x793A;docker&#x7684;&#x7CFB;&#x7EDF;&#x4FE1;&#x606F;,&#x5305;&#x62EC;&#x673A;&#x955C;&#x50CF;&#x548C;&#x5BB9;&#x5668;&#x7684;&#x6570;&#x91CF; &#x66F4;&#x52A0;&#x8BE6;&#x7EC6;&#x7684;&#x4FE1;&#x606F;
docker --help   # &#x5E2E;&#x52A9;&#x547D;&#x4EE4;
</code></pre>
<blockquote>
<p>&#x5E2E;&#x52A9;&#x6587;&#x6863;&#x7684;&#x5730;&#x5740;</p>
</blockquote>
<p><a href="https://docs.docker.com/reference/" target="_blank">https://docs.docker.com/reference/</a></p>
<h4 id="&#x955C;&#x50CF;&#x547D;&#x4EE4;">&#x955C;&#x50CF;&#x547D;&#x4EE4;</h4>
<pre><code class="lang-shell">[root@izijy66dzll7bdz ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
hello-world   latest    d1165f221234   2 weeks ago   13.3kB
[root@izijy66dzll7bdz ~]#
</code></pre>
<p>&#x89E3;&#x91CA;:</p>
<ul>
<li>REPOSITORY &#x955C;&#x50CF;&#x7684;&#x4ED3;&#x5E93;&#x6E90;</li>
<li>TAG &#x955C;&#x50CF;&#x7684;&#x6807;&#x7B7E;</li>
<li>IMAGE ID &#x955C;&#x50CF;&#x7684;ID</li>
<li>CREATED &#x955C;&#x50CF;&#x7684;&#x521B;&#x5EFA;&#x65F6;&#x95F4;</li>
<li>SIZE &#x955C;&#x50CF;&#x7684;&#x5927;&#x5C0F;</li>
</ul>
<blockquote>
<p>docker search &#x641C;&#x7D22;</p>
</blockquote>
<pre><code class="lang-shell">[root@izijy66dzll7bdz ~]# docker search mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relation&#x2026;   10637     [OK]       
mariadb                           MariaDB Server is a high performing open sou&#x2026;   3991      [OK]       
mysql/mysql-server                Optimized MySQL Server Docker images. Create&#x2026;   779                  [OK]
</code></pre>
<p><strong>&#x53EF;&#x4EE5;&#x8FC7;&#x6EE4;&#x641C;&#x7D22;&#x7684;&#x5185;&#x5BB9;:</strong></p>
<pre><code class="lang-bash">[root@iz8g9301trfnpxz /]<span class="hljs-comment"># docker search --help</span>

Usage:    docker search [OPTIONS] TERM

Search the Docker Hub <span class="hljs-keyword">for</span> images
<span class="hljs-comment"># &#x53EF;&#x9009;&#x9879;:&#x901A;&#x8FC7;&#x6536;&#x85CF;&#x6570;&#x91CF;&#x6765;&#x8FC7;&#x6EE4;</span>
Options:
  <span class="hljs-_">-f</span>, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print search using a Go template
      --limit int       Max number of search results (default 25)
      --no-trunc        Don<span class="hljs-string">&apos;t truncate output
[root@iz8g9301trfnpxz /]#
</span></code></pre>
<pre><code class="lang-bash"><span class="hljs-comment">### docker pull &#x4E0B;&#x8F7D;&#x955C;&#x50CF;</span>
[root@iz8g9301trfnpxz /]<span class="hljs-comment"># docker pull mysql</span>
Using default tag: latest
latest: Pulling from library/mysql
6ec8c9369e08: Pull complete 
177e5de89054: Pull complete 
ab6ccb86eb40: Pull complete 
e1ee78841235: Pull complete   <span class="hljs-comment"># &#x5206;&#x5C42;&#x4E0B;&#x8F7D;,docker image&#x7684;&#x6838;&#x5FC3; &#x8054;&#x5408;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF; </span>
09<span class="hljs-built_in">cd</span>86ccee56: Pull complete 
78bea0594a44: Pull complete 
caf5f529ae89: Pull complete 
cf0<span class="hljs-built_in">fc</span>09f046d: Pull complete 
4ccd5b05a8f6: Pull complete 
76d29d8de5d4: Pull complete 
8077a91f5d16: Pull complete 
922753e827ec: Pull complete 
Digest: sha256:fb6a6a26111ba75f9e8487db639bc5721d4431beba4<span class="hljs-built_in">cd</span>668a4e922b8f8b14acc <span class="hljs-comment"># &#x7B7E;&#x540D;</span>
Status: Downloaded newer image <span class="hljs-keyword">for</span> mysql:latest
docker.io/library/mysql:latest  <span class="hljs-comment"># &#x771F;&#x5B9E;&#x5730;&#x5740;</span>


docker pull mysql
docker pull docker.io/library/mysql:latest
&#x8FD9;&#x4E24;&#x4E2A;&#x547D;&#x4EE4;&#x662F;&#x7B49;&#x4EF7;&#x7684;
</code></pre>
<blockquote>
<p>&#x5220;&#x9664;&#x955C;&#x50CF;</p>
</blockquote>
<pre><code class="lang-based">[root@iz8g9301trfnpxz /]# docker rmi -f 8679ced16d20  # &#x5220;&#x9664;&#x955C;&#x50CF;
Untagged: mysql:5.7
Untagged: mysql@sha256:97869b42772dac5b767f4e4692434fbd5e6b86bcb8695d4feafb52b59fe9ae24
Deleted: sha256:8679ced16d206961b35686895b06cfafefde87ef02b518dfc2133081ebf47cda
Deleted: sha256:355f87dc5125a32cc35898a4dde17fb067585bc0d86704b5a467c0ccc0eea484
Deleted: sha256:8299d5c38042216210125535adb2600e46268a0e2b9ec799d12ea5b770236e79
Deleted: sha256:07311a303b2c7cf2ac6992aaf68e12326fe7255985166939cbab7d18b10e0f47
Deleted: sha256:306c9bc1ce2997d000bb6f1ea4108420d9752df93ce39164b7a2f876b954afc4
</code></pre>
<pre><code class="lang-shell">
[root@izijy66dzll7bdz ~]# docker rmi -f &#x955C;&#x50CF;id  # &#x5220;&#x9664;&#x6307;&#x5B9A;&#x7684;&#x955C;&#x50CF;
[root@izijy66dzll7bdz ~]# docker rmi -f &#x955C;&#x50CF;id &#x955C;&#x50CF;id &#x955C;&#x50CF;id # &#x5220;&#x9664;&#x591A;&#x4E2A;&#x955C;&#x50CF;
[root@izijy66dzll7bdz ~]# docker rmi -f $(docker images -aq) # &#x5220;&#x9664;&#x5168;&#x90E8;&#x955C;&#x50CF;
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="docker03 docker原理.html" class="navigation navigation-prev " aria-label="Previous page: docker03 docker原理">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="docker05 容器基本命令.html" class="navigation navigation-next " aria-label="Next page: docker05 容器基本命令">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"docker04 镜像基本命令","level":"1.5","depth":1,"next":{"title":"docker05 容器基本命令","level":"1.6","depth":1,"path":"docker05 容器基本命令.md","ref":"docker05 容器基本命令.md","articles":[]},"previous":{"title":"docker03 docker原理","level":"1.4","depth":1,"path":"docker03 docker原理.md","ref":"docker03 docker原理.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docker04 镜像基本命令.md","mtime":"2021-04-17T07:00:09.705Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:50:48.567Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

